package com.mes.system.controller;

import com.mes.common.pojo.MESResult;
import com.mes.pojo.Dict;
import com.mes.system.service.DictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 侯伟豪
 * @Company 起点编程
 * @Description
 * @Time 2024/10/15 19:11
 */
@RestController
@CrossOrigin
@RequestMapping("/dict")
public class DictController {
    @Autowired
    private DictService dictService;

    @GetMapping("/getDict")
    public MESResult getDict(String dictType){
        return dictService.queryDictAndDataByType(dictType);
    };
    @GetMapping("/dicts")
    public MESResult dicts(String [] dictType){
        return dictService.queryDictAndDataByTypes(dictType);
    };

    @PostMapping("/save")
    public MESResult save(@RequestBody Dict dict){
        return dictService.save(dict);
    };

    @GetMapping("/list")
    public MESResult list(Dict dict, @RequestParam(defaultValue = "1")int page,@RequestParam(defaultValue = "10") int limit){
        return dictService.list(dict,page,limit);
    };
    @GetMapping("getDataList")
    public MESResult dataList(Long dictId){
        return dictService.dataList(dictId);
    }
    @GetMapping("/get")
    public MESResult get(Long dictId){
        return dictService.get(dictId);
    };
    @PutMapping("/update")
    public MESResult update(@RequestBody Dict dict){
        return dictService.update(dict);
    };

    @DeleteMapping("/delete")
    public MESResult delete(Long dictId){
        return dictService.delete(dictId);
    };
    @DeleteMapping("/deletes")
    public MESResult deletes(Long [] dictId){
        return dictService.deletes(dictId);
    }
}